package leetcode.editor.cn.q1xx

class Q118 {

    fun generate(numRows: Int): List<List<Int>> {
        val result = ArrayList<ArrayList<Int>>()
        for (i in 0 until numRows) {
            if (i == 0) {
                result.add(arrayListOf(1))
            } else {
                val list = arrayListOf<Int>()
                list.add(1)
                for (j in 1 until i) {
                    list.add(result[i - 1][j - 1] + result[i - 1][j])
                }
                list.add(1)
                result.add(list)
            }
        }
        return result
    }
}